package com.chartboost.sdk.Libraries;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import com.chartboost.sdk.Chartboost;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.security.auth.x500.X500Principal;
import org.json.JSONArray;
import org.json.JSONObject;

public class d
{
  private static String a = null;
  private static final X500Principal b = new X500Principal("CN=Android Debug,O=Android,C=US");

  public static int a(int paramInt, Context paramContext)
  {
    return Math.round(paramInt * b(paramContext));
  }

  public static SharedPreferences a()
  {
    return Chartboost.sharedChartboost().getContext().getSharedPreferences("cbPrefs", 0);
  }

  public static String a(Map<String, String> paramMap)
  {
    if (paramMap == null)
      return "";
    StringBuilder localStringBuilder = new StringBuilder();
    if (!paramMap.keySet().isEmpty())
      localStringBuilder.append("?");
    Iterator localIterator = paramMap.keySet().iterator();
    if (!localIterator.hasNext())
      return localStringBuilder.toString();
    String str1 = (String)localIterator.next();
    if (localStringBuilder.length() > 0)
      localStringBuilder.append("&");
    String str2 = (String)paramMap.get(str1);
    if (str1 != null);
    while (true)
    {
      try
      {
        str3 = URLEncoder.encode(str1, "UTF-8");
        localStringBuilder.append(str3);
        localStringBuilder.append("=");
        if (str2 == null)
          break label169;
        str4 = URLEncoder.encode(str2, "UTF-8");
        localStringBuilder.append(str4);
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        throw new RuntimeException("This method requires UTF-8 encoding support", localUnsupportedEncodingException);
      }
      String str3 = "";
      continue;
      label169: String str4 = "";
    }
  }

  public static List<String> a(JSONArray paramJSONArray)
  {
    if (paramJSONArray == null)
      return null;
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    while (true)
    {
      if (i >= paramJSONArray.length())
        return localArrayList;
      try
      {
        localArrayList.add(paramJSONArray.getString(i));
        label38: i++;
      }
      catch (Exception localException)
      {
        break label38;
      }
    }
  }

  public static Map<String, String> a(JSONObject paramJSONObject)
  {
    if (paramJSONObject == null)
      return null;
    HashMap localHashMap = new HashMap();
    Iterator localIterator = paramJSONObject.keys();
    while (true)
    {
      if (!localIterator.hasNext())
        return localHashMap;
      try
      {
        String str = (String)localIterator.next();
        localHashMap.put(str, paramJSONObject.getString(str));
      }
      catch (Exception localException)
      {
      }
    }
  }

  public static JSONArray a(List<String> paramList)
  {
    if (paramList == null)
      return null;
    JSONArray localJSONArray = new JSONArray();
    int i = 0;
    while (true)
    {
      if (i >= paramList.size())
        return localJSONArray;
      try
      {
        localJSONArray.put(paramList.get(i));
        label40: i++;
      }
      catch (Exception localException)
      {
        break label40;
      }
    }
  }

  public static boolean a(Context paramContext)
  {
    try
    {
      arrayOfSignature = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 64).signatures;
      k = 0;
      m = 0;
    }
    catch (Exception localException1)
    {
      try
      {
        Signature[] arrayOfSignature;
        int k;
        int n = arrayOfSignature.length;
        if (k >= n)
          i = m;
        while (true)
        {
          label39: if ((0x2 & paramContext.getApplicationInfo().flags) != 0);
          for (int j = 1; ; j = 0)
          {
            return i | j;
            boolean bool = ((X509Certificate)CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(arrayOfSignature[k].toByteArray()))).getSubjectX500Principal().equals(b);
            i = bool;
            if (i != 0)
              break label39;
            k++;
            m = i;
            break;
          }
          localException1 = localException1;
          i = 0;
        }
      }
      catch (Exception localException2)
      {
        while (true)
        {
          int m;
          int i = m;
        }
      }
    }
  }

  public static float b(int paramInt, Context paramContext)
  {
    return paramInt * b(paramContext);
  }

  public static float b(Context paramContext)
  {
    return paramContext.getResources().getDisplayMetrics().density;
  }

  public static String b()
  {
    if (c())
      return null;
    if (a != null)
      return a;
    a = c.a();
    return a;
  }

  public static JSONObject b(Map<String, String> paramMap)
  {
    if (paramMap == null)
      return null;
    JSONObject localJSONObject = new JSONObject();
    Iterator localIterator = paramMap.entrySet().iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return localJSONObject;
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      String str = (String)localEntry.getKey();
      Object localObject = localEntry.getValue();
      try
      {
        localJSONObject.put(str, localObject);
      }
      catch (Exception localException)
      {
      }
    }
  }

  public static CBOrientation c(Context paramContext)
  {
    Display localDisplay = ((WindowManager)paramContext.getSystemService("window")).getDefaultDisplay();
    int i = paramContext.getResources().getConfiguration().orientation;
    int j = localDisplay.getRotation();
    int k;
    int m;
    if (localDisplay.getWidth() == localDisplay.getHeight())
    {
      k = 3;
      if (k != 1)
        break label123;
      m = 1;
    }
    while (true)
    {
      label55: if ((j == 0) || (j == 2));
      while (true)
        if (m != 0)
          switch (j)
          {
          default:
            return CBOrientation.PORTRAIT;
            if (localDisplay.getWidth() < localDisplay.getHeight())
            {
              k = 1;
              break;
            }
            k = 2;
            break;
            if (k == 2)
            {
              m = 0;
              break label55;
            }
            if (k != 3)
              break label236;
            if (i == 1)
            {
              m = 1;
              break label55;
            }
            if (i != 2)
              break label236;
            m = 0;
            break label55;
            if (m != 0)
              m = 0;
            else
              m = 1;
            break;
          case 1:
            return CBOrientation.LANDSCAPE_LEFT;
          case 2:
            return CBOrientation.PORTRAIT_REVERSE;
          case 3:
            label123: return CBOrientation.LANDSCAPE_RIGHT;
          }
      switch (j)
      {
      default:
        return CBOrientation.LANDSCAPE;
      case 1:
        return CBOrientation.PORTRAIT_LEFT;
      case 2:
        return CBOrientation.LANDSCAPE_REVERSE;
      case 3:
      }
      return CBOrientation.PORTRAIT_RIGHT;
      label236: m = 1;
    }
  }

  public static boolean c()
  {
    return a().getBoolean("cbIdentityTrackingDisabled", false);
  }

  public static boolean d()
  {
    return Looper.myLooper() == Looper.getMainLooper();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.chartboost.sdk.Libraries.d
 * JD-Core Version:    0.6.2
 */